package org.yyf.resource.demo.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 简单线程 线程池
 * @author yyf
 * @date 2019年9月5日
 */
public class SimpleThread extends Thread{
	
	private String name;
	
	public SimpleThread(String name) {
		this.name = name;
	}

	@Override
	public void run() {
		while(true) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println("hello "+name);
		}
	}
	
	public static void main(String[] args) {
//		SimpleThread s = new SimpleThread("yyf");
//		s.start();
		
		int size = 5;
		ExecutorService excutor = Executors.newFixedThreadPool(size);
		
		for(int i = 0;i<size;i++) {
			SimpleThread thread = new SimpleThread("yyf"+i);
			excutor.execute(thread);
		}
		
	}
	
}
